/*
 * 文件名：IGenericDao.java
 * 版权：Copyright by www.wootide.com
 * 描述：
 * 修改人：qianfm
 * 修改时间：Sep 11, 2012
 * 跟踪单号：
 * 修改单号：
 * 修改内容：
 */
package com.wootide.cms.manager.dao;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;

import org.hibernate.LockMode;
import org.springframework.dao.DataAccessException;

/**
 * DAO 泛型接口
 * @author qianfm
 * @version Sep 11, 2012
 * @see IGenericDao
 * @since
 */

public interface IGenericDAO<T, ID extends Serializable>
{
    /**
     * 
     * 查询对象 <br>
     * Implement: <br>
     * @param id
     * @return
     * @throws DataAccessException
     * @see
     * @return T
     * @author qianfm
     */
    public T load(ID id) throws DataAccessException;
    
    /**
     * 
     * 查询对象: <br>
     * Implement: <br>
     * @param id
     * @return
     * @throws DataAccessException
     * @see
     * @return T
     * @author qianfm
     */
    public T get(ID id) throws DataAccessException;
    
    /**
     * 
     * 是否已经存在 <br>
     * Implement: <br>
     * @param t
     * @return
     * @throws DataAccessException
     * @see
     * @return boolean
     * @author qianfm
     */
    public boolean contains(T t) throws DataAccessException;
    
    /**
     * 
     * 刷新对象 <br>
     * Implement: <br>
     * @param t
     * @param lockMode
     * @throws DataAccessException
     * @see
     * @return void
     * @author qianfm
     */
    public void refresh(T t, LockMode lockMode) throws DataAccessException;
    
    /**
     * 
     * 刷新对象: <br>
     * Implement: <br>
     * @param t
     * @throws DataAccessException
     * @see
     * @return void
     * @author qianfm
     */
    public void refresh(T t) throws DataAccessException;
    
    /**
     * 
     * 保存 <br>
     * Implement: <br>
     * @param t
     * @return
     * @throws DataAccessException
     * @see
     * @return Serializable
     * @author qianfm
     */
    public Serializable save(T t) throws DataAccessException;
    
    /**
     * 
     * 保存或者更新 <br>
     * Implement: <br>
     * @param t
     * @throws DataAccessException
     * @see
     * @return void
     * @author qianfm
     */
    public void saveOrUpdate(T t) throws DataAccessException;
    
    /**
     * 
     * 保存或更新所有 <br>
     * Implement: <br>
     * @param entities
     * @throws DataAccessException
     * @see
     * @return void
     * @author qianfm
     */
    public void saveOrUpdateAll(Collection<T> entities)
            throws DataAccessException;
    
    /**
     * 
     * 更新 <br>
     * Implement: <br>
     * @param t
     * @param lockMode
     * @throws DataAccessException
     * @see
     * @return void
     * @author qianfm
     */
    public void update(T t, LockMode lockMode) throws DataAccessException;
    
    /**
     * 
     * 更新 <br>
     * Implement: <br>
     * @param t
     * @throws DataAccessException
     * @see
     * @return void
     * @author qianfm
     */
    public void update(T t) throws DataAccessException;
    
    /**
     * 
     * 删除 <br>
     * Implement: <br>
     * @param t
     * @param lockMode
     * @throws DataAccessException
     * @see
     * @return void
     * @author qianfm
     */
    public void delete(T t, LockMode lockMode) throws DataAccessException;
    
    /**
     * 
     * 删除单个对象 <br>
     * Implement: <br>
     * @param t
     * @throws DataAccessException
     * @see
     * @return void
     * @author qianfm
     */
    public void delete(T t) throws DataAccessException;
    
    /**
     * 
     * 删除集合 <br>
     * Implement: <br>
     * @param entities
     * @throws DataAccessException
     * @see
     * @return void
     * @author qianfm
     */
    public void deleteAll(Collection<T> entities) throws DataAccessException;
    
    /**
     * 
     * 根据语句查询  <br>
     * Implement: <br>
     * @param queryString
     * @param value
     * @return
     * @throws DataAccessException
     * @see
     * @return List<T>
     * @author qianfm
     */
    public List<T> find(String queryString, Object value)
            throws DataAccessException;
    
    /**
     * 
     * 根据语句查询 <br>
     * Implement: <br>
     * @param queryString
     * @param values
     * @return
     * @throws DataAccessException
     * @see
     * @return List<T>
     * @author qianfm
     */
    public List<T> find(String queryString, Object[] values)
            throws DataAccessException;
    
    /**
     * 
     * 根据语句查询 <br>
     * Implement: <br>
     * @param queryString
     * @return
     * @throws DataAccessException
     * @see
     * @return List<T>
     * @author qianfm
     */
    public List<T> find(String queryString) throws DataAccessException;
    
    /**
     * 
     * 查询对象列表 <br>
     * Implement: <br>
     * @return
     * @throws DataAccessException
     * @see
     * @return List<T>
     * @author qianfm
     */
    public List<T> list() throws DataAccessException;
    
    /**
     * 
     * 根据语句查询 <br>
     * Implement: <br>
     * @param queryName
     * @return
     * @throws DataAccessException
     * @see
     * @return List<T>
     * @author qianfm
     */
    public List<T> findByNamedQuery(String queryName)
            throws DataAccessException;
    
    /**
     * 
     * 根据语句查询 <br>
     * Implement: <br>
     * @param queryName
     * @param value
     * @return
     * @throws DataAccessException
     * @see
     * @return List<T>
     * @author qianfm
     */
    public List<T> findByNamedQuery(String queryName, Object value)
            throws DataAccessException;
    
    /**
     * 
     * 根据语句查询 <br>
     * Implement: <br>
     * @param queryName
     * @param values
     * @return
     * @throws DataAccessException
     * @see
     * @return List<T>
     * @author qianfm
     */
    public List<T> findByNamedQuery(String queryName, Object[] values)
            throws DataAccessException;
    
    //    public PaginationSupport findPageByCriteria(
    //            final DetachedCriteria detachedCriteria, final int pageSize,
    //            final int startIndex);
    //    
    //    public PaginationSupport findPageByQuery(final String hql,
    //            final String countHql, final int pageSize, final int startIndex);
    
}
